package com.example.ByteStream;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @author Jason
 * @PACKAGE_NAME com.example.ByteStream
 * @Description 序列化ObjectOutputStream写入操作
 * @date 2023-12-11 21:41
 */
public class ObjectOutputStreamDemo {
    public static void main(String[] args) throws IOException {
        //1.创建一个对象流
        FileOutputStream fos = new FileOutputStream("d:\\aaa.ini");
        ObjectOutputStream oos = new ObjectOutputStream(fos);

        //2.序列化写入
        Student zhangsan = new Student("zhangsan", 20);
        oos.writeObject(zhangsan);
        //3.关闭
        oos.close();
        System.out.println("序列化关闭");
    }
}
